package App.Controller;

import App.Model.BaseResponse;
import App.Model.LoginResponse;
import App.Model.Version.GetAppVersionRequest;
import App.Service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by xw on 2019/5/5.
 */

@RestController
@RequestMapping("/api/version/")
public class VersionController extends BaseController {

    @Autowired
    private AccountService _service;

    @RequestMapping(value = "getversion", method = RequestMethod.POST)
    public ResponseEntity<LoginResponse> login(@RequestBody(required = false) GetAppVersionRequest _request) {
        if (_request == null) {
            BaseResponse _baseResponse = ResponseError(null, "参数格式错误");
            return new ResponseEntity(_baseResponse, HttpStatus.OK);
        }
        Object result = null;
        try {
            result = _service.getVersionNO(_request.getApptype());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return new ResponseEntity(result, HttpStatus.OK);
    }


}
